#ifndef MAINWINDOWCRACK_H
#define MAINWINDOWCRACK_H

#include <QWidget>
#include <QVector>
#include <QMessageBox>
#include <QDateTime>
#include <QPluginLoader>
#include "settingformcrack.h"
#include "qneedleindicator.h"
#include "BruteForceClass.h"
#include "SlaveSlot.h"
#include "qdisplay.h"
//
// specify the number of slave slot
#define kMaxSlotPerRow      2
#define kMaxSlotPerCol      5
//
// specify the len of display of combination:
#define kMaxCharDisplayComb 15 // change only this one
//
// do not modify that below:
#define kFillDisplayComb(ch)   QString(kMaxCharDisplayComb, (ch)).toUtf8().constData()
//
// setting keys for generation process:
#define kOrganization           "libGenCrack"
#define kKeyWordFileName        "dictionaryFile"
#define kKeyParallelThreadRead  "numThread"
#define kKeyPrefixChars         "prefixString"
#define kKeyPrefixRangeStart    "prefixStart"
#define kKeyPrefixRangeEnd      "prefixEnd"
#define kKeyPostfixChars        "postfixString"
#define kKeyPostfixRangeStart   "postfixStart"
#define kKeyPostfixRangeEnd     "postfixEnd"


namespace Ui {
    class MainWindowCrack;
}

class MainWindowCrack : public QWidget {
    Q_OBJECT
private:
    void                    createSlaveSlots(void);
    BruteForceClass *       createNewEngine(void);
    void                    destroyEngine(void);

public:
    QDisplay                lcdSlaveConnected;
    QDisplay                lcdOutputCombination;
    QPluginLoader           *pluginLoader;
    quint64                 totalEffectedCombinations; // incremented by one in callback_new_combination
    TInfoBruteForce         *detailBruteForce;

    MainWindowCrack(QWidget *parent = 0);
    ~MainWindowCrack();

    void                    resetAllSlaveSlots(void);

protected:
    void changeEvent(QEvent *e);
    void closeEvent(QCloseEvent *event);

public slots:
    void writeToLog(QString newLog);
    void timeout(void);
    void updateMasterQueueIndicator(quint64 units);

private:    
    Ui::MainWindowCrack     *ui;
    QVector<SlaveSlot *>    m_SlavesList; // a list of all slave connected    
    QGridLayout             *m_gridLayoutSlave;
    QLedIndicator           *m_ledConnectionStatus;
    QNeedleIndicator        *m_queueIndicator;
    QTimer                  *m_timerForLedBlinking;    
    BruteForceClass         *m_engineBruteForce;

private slots:
    void on_cmdPluginSelect_clicked();
    void on_cmdBruteForceSetting_clicked();
    void on_cmdAvviaGridComputing_clicked();
    void on_cmdChiudiMaster_clicked();
    void on_cmdAttivaMaster_clicked();
};

#endif // MAINWINDOWCRACK_H
